<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加药品</title>
    <link href="bootstrap-4.6.1-dist/css/bootstrap.min.css"
          rel="stylesheet" type="text/css">
    <style type="text/css">
        #main{
            margin-top: 20px;
            margin-left: 30px;
            margin-right: 30px;
        }
    </style>
</head>
<body>
<div id="main">
    <nav class="navbar navbar-expand-lg navbar-light" style="background-color: #e3f2fd;">
        <a class="navbar-brand" href="#">菜单</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
                aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" href="Doctor.html">医生管理</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="medicine.html">药品管理</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="Register.html">挂号管理</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link justify-content-end" href="login.html">退出</a>
                </li>
            </ul>
        </div>
    </nav>
    <form id="form">
        <table class="table table-bordered">
            <tr>
                <td width="100" class="bg-secondary">药品编号</td>
                <td>
                    <input type="text" name="medicineId">
                </td>
            </tr>
            <tr>
                <td width="100" class="bg-secondary">进价</td>
                <td>
                    <input type="text" name="inPrice">
                </td>
            </tr>
            <tr>
                <td width="100" class="bg-secondary">售价</td>
                <td>
                    <input type="text" name="salPrice">
                </td>
            </tr>
            <tr>
                <td width="100" class="bg-secondary">数量</td>
                <td>
                    <input type="text" name="mcount">
                </td>
            </tr>
            <tr>
                <td width="100" class="bg-secondary">药品名称</td>
                <td>
                    <input type="text" name="medicineName">
                </td>
            </tr>
            <tr>
                <td width="100" class="bg-secondary">药品类型</td>
                <td>
                    <input type="radio" name="medicineType" value="1">处方药
                    <input type="radio" name="medicineType" value="2">中药
                    <input type="radio" name="medicineType" value="3">西药
                </td>
            </tr>
            <tr>
                <td width="100" class="bg-secondary">简单描述</td>
                <td>
                    <input type="text" name="descs">
                </td>
            </tr>
            <tr>
                <td width="100" class="bg-secondary">保质期</td>
                <td>
                    <input type="text" name="qualityDate">月
                </td>
            </tr>
            <tr>
                <td width="100" class="bg-secondary">详细描述</td>
                <td>
                    <input type="text" name="description">
                </td>
            </tr>
            <tr>
                <td width="100" class="bg-secondary">生产厂商</td>
                <td>
                    <input type="text" name="produceFirm">
                </td>
            </tr>
            <tr>
                <td width="100" class="bg-secondary">服用说明</td>
                <td>
                    <input type="text" name="readme">
                </td>
            </tr>
            <tr>
                <td width="100" class="bg-secondary">备注</td>
                <td>
                    <input type="text" name="remark">
                </td>
            </tr>
            <tr>
                <td colspan="2" class="text-center">
                    <button type="button" id="Btnadd" class="btn btn-sm btn-info">保存</button>
                    <a role="button" class="btn btn-sm btn-success" href="medicine.html">返回列表</a>
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
<script src="jQuery/jquery-3.6.0.min.js"></script>
<script>
    jQuery(function () {
        jQuery("#Btnadd").click(function () {
            let form=jQuery("#form").serialize();
            jQuery.post("medicine/reg",form,function (rst) {
                if(rst>0){
                    alert("添加成功!");
                    window.location.href="medicineAdd.html";
                }else {
                    alert("添加失败!");
                }
            });
        });
    })
</script>
</html>